package com.wc.AlgoOJ_homework.AlgoOJ_HomeWork2.D_最少刷题数;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/5 18:23
 * @description http://43.138.190.70:8888/p/LQ1315?tid=65e6b15c27489dab814f8d41
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    // exNum[i]表示超过i的个数
    static int[] exMum = new int[N];
    // laNum[i]表示小于i的个数
    static int[] laNum = new int[N];
    // 原数组
    static int[] a = new int[N];
    static int n;

    public static void main(String[] args) {
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
            int l = 1;
            int r = a[i];
            // 也就是是超过 l-1 但是不超过r
            exMum[l - 1] += 1;
            exMum[r] -= 1;
            // 比r+1小
            laNum[r + 1] += 1;
            // 最大的一定是N - 1
            laNum[N - 1] -= 1;
        }
        for (int i = 1; i < N; i++) {
            exMum[i] += exMum[i - 1];
            laNum[i] += laNum[i - 1];
        }

        for (int i = 1; i <= n; i++) {
            int next = a[i];
            // 如果满足就直接输出0
            if (exMum[next] <= laNum[next]) {
                out.print("0 ");
                continue;
            }
            // 不满足就加一个1
            next++;
            // 比next大的永远比next大,但是比next小的是少了一个，因为他a[i]变成next了
            while (exMum[next] > laNum[next] - 1) {
                next++;
            }
            out.print(next - a[i] + " ");
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
